import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import './plugins/element.js'
/////////////////////////////////////////////////////导入加载进度条依赖包
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

//////////////////////////////////////////////////////配置axios请求
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
//配置请求拦截器
axios.interceptors.request.use(config => {
    // console.log(config);
    //显示进度条
    NProgress.start();

    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
})
axios.interceptors.response.use(config => {
    //隐藏进度条
    NProgress.done();
    return config
})
Vue.prototype.$http = axios;

///////////////////////////////////////////////////////全局过滤器
Vue.filter('dateFormat', function(originVal) {
    const dt = new Date(originVal * 1000)
    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')
    const hh = (dt.getHours() + '').padStart(2, '0')
    const mn = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mn}:${ss}`
});

/////////////////////////////////////////////////////表格全局注册
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)

/////////////////////////////////////////////////////////////副文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)

//取消生产模式消息
Vue.config.productionTip = false;
//创建vue实例
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')